home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 24 / MacAddict_024_1998_08.iso / Media / Software.dxr / LingoLib_12_v12 Database code.ls < prev    next >
Encoding:
Text File  |  1998-06-04  |  2.0 KB  |  84 lines

  1. on workThatV12Magic
  2.   put "V12dbe v2.0.2" & RETURN & "code last modified 10/28/97"
  3.   put "opening the v12 xtras"
  4.   openV12xtras()
  5.   put "creating v12 database"
  6.   createV12DB()
  7.   put "opening the v12 database"
  8.   openV12DB()
  9.   put "importing textfile into database"
  10.   ImportData()
  11.   put "closing the v12 database"
  12.   closeV12()
  13. end
  14.  
  15. on openV12xtras
  16.   global gDb, gTB
  17.   openXLib(the pathName & "xtras:V12-DBE")
  18.   openXLib(the pathName & "xtras:V12table")
  19. end
  20.  
  21. on createV12DB
  22.   global gDb, gTB
  23.   set gDb to new(xtra("v12dbe"), the pathName & "ShareWare.db", "Create", "myPassword")
  24.   if not objectp(gDb) then
  25.     alert("Could not create the an instance of the V12dbe Xtra.")
  26.   end if
  27.   mCreateTable(gDb, "Table")
  28.   if checkError() then
  29.     halt()
  30.   end if
  31.   mCreateField(gDb, "Table", "section", "string", 300)
  32.   checkError()
  33.   mCreateField(gDb, "Table", "category", "string", 300)
  34.   checkError()
  35.   mCreateField(gDb, "Table", "name", "string", 300)
  36.   checkError()
  37.   mCreateField(gDb, "Table", "filepath", "string", 300)
  38.   checkError()
  39.   mCreateField(gDb, "Table", "auth/comp", "string", 300)
  40.   checkError()
  41.   mCreateField(gDb, "Table", "url", "string", 300)
  42.   checkError()
  43.   mCreateField(gDb, "Table", "version", "string", 300)
  44.   checkError()
  45.   mCreateField(gDb, "Table", "description", "string", 3000)
  46.   checkError()
  47.   mCreateField(gDb, "Table", "contact", "string", 1000)
  48.   checkError()
  49.   mCreateIndex(gDb, "Table", "categoryIndex", "duplicate", "category", "descending")
  50.   checkError()
  51.   mCreateFullIndex(gDb, "Table", "description")
  52.   checkError()
  53.   put mBuild(gDb)
  54.   checkError()
  55.   closeV12()
  56. end
  57.  
  58. on openV12DB
  59.   global gDb, gTB
  60.   set gDb to new(xtra("v12dbe"), the pathName & "ShareWare.db", "ReadWrite", "myPassword")
  61.   set gTB to new(xtra("v12table"), mGetRef(gDb), "Table")
  62. end
  63.  
  64. on ImportData
  65.   global gDb, gTB
  66.   mImportFile(gTB, the pathName & "sharew.txt", TAB, RETURN)
  67.   checkError()
  68.   closeV12()
  69. end
  70.  
  71. on checkError
  72.   if mStatus(xtra("v12dbe")) <> 0 then
  73.     put mError(xtra("v12dbe"))
  74.     return 1
  75.   end if
  76.   return 0
  77. end
  78.  
  79. on closeV12
  80.   global gDb, gTB
  81.   set gDb to 0
  82.   set gTB to 0
  83. end
  84.